package gui.newgui.archerdbeditor;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JTable;

public class NewArcherDbEditorMouseListener implements MouseListener {
	private final NewArcherDBEditor window;

	public NewArcherDbEditorMouseListener(NewArcherDBEditor newArcherDBEditor) {
		this.window = newArcherDBEditor;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		if (e.getSource() instanceof JTable) {
			try {
				((NewArcherDBEditorController) this.window.getController()).filloutForm();
				/** in case of changing checkbox-value, save immediately */
				if ((this.window.getTable().getSelectedColumn() == 9) || (this.window.getTable().getSelectedColumn() == 10)) {
					((NewArcherDBEditorController) this.window.getController()).saveEntry(true);
				}
			} catch (IndexOutOfBoundsException e1) {

			}
		} else if (e.getSource() == this.window.getMakeEditableCheckBox()) {
			((NewArcherDBEditorController) this.window.getController()).makeDropDownsEditable(this.window.getMakeEditableCheckBox().isSelected());
		}
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub

	}

}
